import '../config/AppConst.dart';
import '../utils/SpUtils.dart';
import '../utils/TimeUtils.dart';

class ClassicesHelp {
  //今天
  static String getToday(int? lastScoreTime, DateTime nowTime) {
    if (lastScoreTime == null || lastScoreTime == 0) {
      return '0';
    } else {
      if (TimeUtils.gtTime6(nowTime) ==
          TimeUtils.gtTime6(
              DateTime.fromMillisecondsSinceEpoch(lastScoreTime))) {
        //上次保存的在今天
        return '${SpUtils.getInstance()?.getInt(AppConst.todayScore)}';
      } else {
        //不再一天了
        return '0';
      }
    }
  }

  //本周
  static String getWeekday(int? lastScoreTime, DateTime nowTime) {
    if (lastScoreTime == null || lastScoreTime == 0) {
      return '0';
    } else {
      if (TimeUtils.IsBetweenOneWeek(lastScoreTime)) {
        //在本周了
        return '${SpUtils.getInstance()?.getInt(AppConst.weekScore)}';
      } else {
        return '0';
      }
    }
  }

  //再本月
  static String getMonth(int? lastScoreTime, DateTime nowTime) {
    if (lastScoreTime == null || lastScoreTime == 0) {
      return '0';
    } else {
      if (TimeUtils.gtTime(DateTime.now()) ==
          TimeUtils.gtTime(
              DateTime.fromMillisecondsSinceEpoch(lastScoreTime))) {
        //在本月
        return '${SpUtils.getInstance()?.getInt(AppConst.monthScore)}';
      } else {
        return '0';
      }
    }
  }

//本年
  static String getyear(int? lastScoreTime, DateTime nowTime) {
    if (lastScoreTime == null || lastScoreTime == 0) {
      return '0';
    } else {
      if (nowTime.year ==
          DateTime.fromMillisecondsSinceEpoch(lastScoreTime).year) {
        //在本年
        return '${SpUtils.getInstance()?.getInt(AppConst.yearScore)}';
      } else {
        return '0';
      }
    }
  }

  //历史
  static String getHistory(int? lastScoreTime, DateTime nowTime) {
    if (lastScoreTime == null || lastScoreTime == 0) {
      return '0';
    } else {
      //历史
      return '${SpUtils.getInstance()?.getInt(AppConst.historyScore)}';
    }
  }
}
